var formatDate = function(value){
	if(value == null){
		return "";
	}
	var createDate = new Date(value);
	var year = createDate.getFullYear();
	var mouth = add_zero(createDate.getMonth()+1);
	var day = add_zero(createDate.getDate());
	var hh = add_zero(createDate.getHours());
	var mm = add_zero(createDate.getMinutes());
	var ss = add_zero(createDate.getSeconds());
	return year+"-"+mouth+"-"+day+" "+hh+":"+mm+":"+ss;
}
 function getLocalTime(i,value) {
        //参数i为时区值数字，比如北京为东八区则输进8,西5输入-5
        if (typeof i !== 'number') return;
        var d = new Date();
        //得到1970年一月一日到现在的秒数
        var len = value;
        //本地时间与GMT时间的时间偏移差
        var offset = d.getTimezoneOffset() * 60000;
        //得到现在的格林尼治时间
        var utcTime = len + offset;
        return formatDate(utcTime + 3600000 * i);
    }
var add_zero = function(temp)
{
 if(temp<10) return "0"+temp;
 else return temp;
}
//设置左分隔符为 <!
baidu.template.LEFT_DELIMITER='<$';
//设置右分隔符为 <!
baidu.template.RIGHT_DELIMITER='$>';
$('.grid').isotope({
  // options
  itemSelector: '.grid-item',
  layoutMode: 'fitRows'
});
$(".cupBtn").click(function(){
           //初始化统计数据
           var cupId = $(this).attr("cupId");
           var cupName = $(this).attr("cupName");
               $.post('/todayCupMatchList',{"cupId":cupId},function(data){
                     console.log(data);
                     var data = {"cupInfo":data,"cupName":cupName,"cupId":cupId}
                      var result = baidu.template('cupInfo',data);
                      $("#cupInfoModel").html(result);
                      $(".battleBtn").click(function(){
                            var cupId = $(this).attr("cupId");
                            var homeId = $(this).attr("hostId");
                            var visitorId = $(this).attr("visitorId");
                            window.open("./teamBattle?cupId="+cupId+"&hostId="+homeId+"&visitorId="+visitorId);
                      });
                      $('#cupInfoModel').modal('show');

                });

});
$("#mySfBtn").click(function(){
    window.open("./teamBattle?cupId="+cupId+"&hostId="+homeId+"&visitorId="+visitorId);
});

